trim his sails to the wind

vi.见风使舵,随机应变